#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
using namespace std;

const int N = 1e5 + 10;

int n;
int cost[N];
int dp[N];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> cost[i];

	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
	}

	cout << dp[n] << endl;
	return 0;
}